<template>
  <Container class="dealer-pointmodify-list">
    <HeadFormItem
    slot="header"
      :list="list"
      @onSearchBtnClick="onSearchBtnClick"
    />
    <Tabs v-model="tab">
      <TabPane label="经销商积分奖惩" name="tab1">
         <homeTable
          :list="list"
          @getData="getData"
          @onPageSizeChange="onPageSizeChange"
          @onPageChange="onPageChange"
          @onSelectionChange="onSelectionChange"
        />
      </TabPane>
    </Tabs>
    <DealerPointDetailModelItem ref="ModelItem" />
  </Container>
</template>
<script>
import DealerPointModifyListData from './list/DealerPointModifyListData'
import HeadFormItem from './list/HeadFormItem'
import DealerPointDetailModelItem from './list/DealerPointDetailModelItem'
import homeTable from '@/components/homeTable'

import { clearEmpty, formatDate } from '@/util'
export default {
  name: 'welfare/dealerpointmodify/list',
  components: {
    HeadFormItem,
    DealerPointDetailModelItem,
    homeTable
  },
  data() {
    return {
      tab: "tab1",
      list: DealerPointModifyListData,
      productIds: []
    };
  },
  mounted() {
    // this.list.currentPage = ~~this.$route.query.currentPage || 1;
    // this.list.pageSize = ~~this.$route.query.pageSize || this.list.pageSize;
    this.getData()
    this.$bus.$on('checklRow', this.checklRow)
  },
  destroyed() {
    this.$bus.$off();
  },
  methods: {
    onSearchBtnClick() {
      this.list.currentPage = 1;
      this.getData();
    },
    checklRow(row) {
      this.$refs.ModelItem.openModal(row)
    },
    getData() {
      this.list.status = "loading";
      let param = {
        current: this.list.currentPage,
        size: this.list.pageSize,
        ...this.list.form
        // officeId: this.list.form.officeId,
        // departmentId: this.list.form.departmentId,
        // brandId: this.list.form.brandId,
        // distributorId: this.list.form.distributorId
      };
      param = clearEmpty(param)
      this.$ajaxGet("/distributor/contract/findByQuery", param).then(data => {
          this.list.data = [];
          this.list.totalItem = Number(data.total);
          this.list.totalItem = Number(data.total);
          this.list.data = (data.records || [])
          this.list.status = "pass";
        })
        .catch(() => {
          this.list.status = "error";
        });
    },
    onSelectionChange(selection) {
      this.productIds = (selection || []).map(item => item.id);
    },
    onPageChange(number) {
      this.list.currentPage = number;
      this.getData();
    },
    onPageSizeChange(pageSize) {
      this.list.currentPage = 1;
      this.list.pageSize = pageSize;
      this.getData();
    },
    onRefresh() {
      this.getData();
    },
    onExport() {
      this.$Message.info('导出')
    },
  },
  watch: {
  }
};
</script>
